//
//  RefundViewController.m
//  phmall
//
//  Created by admin on 2017/12/16.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "RefundViewController.h"
#import "Orderheader.h"
#import "ApplyRefundVC.h"
#import "RefundCell.h"
#import "RefundScheduleVC.h"
@interface RefundViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    Orderheader *_headView;
}
@property(nonatomic,strong)UITableView *myTableview;
@end

@implementation RefundViewController
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navBarBgAlpha=@"1.0";
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=Localized(@"售后服务");
    UIBarButtonItem* leftBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarAction)];
    self.navigationItem.leftBarButtonItem=leftBar;
    
    [self setUI];
    // Do any additional setup after loading the view.
}
-(void)setUI{
    //消除强引用
    __weak typeof(self) weakSelf = self;
    _headView = [[Orderheader alloc]init];
    [self.view addSubview:_headView];
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view);
        make.height.offset(40);
    }];
    _headView.backgroundColor=[UIColor colorWithHexString:@"#f8fafd"];
    _headView.itemClickAtIndex = ^(NSInteger index){
//        [weakSelf adjustScrollView:index];
//        weakSelf.hidesBottomBarWhenPushed=YES;
//        RefundScheduleVC *evaluate=[[RefundScheduleVC alloc]init];
//        [weakSelf.navigationController pushViewController:evaluate animated:YES];
    };
    _headView.items = @[Localized(@"申请售后"),Localized(@"申请进度")];
    
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(40);
        make.left.right.equalTo(self.view).priorityHigh();
        make.bottom.equalTo(self.view).with.offset(-self.tabBar_height).priorityHigh();
    }];
}
#pragma mark - tableView
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    //    OrderModel *model=self.orderList[section];
    //    NSMutableArray *data=model.goods_list;
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 44;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}


-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
    view.backgroundColor=[UIColor whiteColor];
    //    OrderModel *model=self.orderList[section];
    
    UILabel *number=[[UILabel alloc]init];
    number.text=@"订单编号:OD150753966532";
    number.font=[UIFont systemFontOfSize:16];
    [view addSubview:number];
    [number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.centerY.equalTo(view);
    }];
    
    UIView *line=[[UIView alloc]init];
    line.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [view addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view).offset(00);
        make.right.equalTo(view).offset(0);
        make.bottom.equalTo(view);
        make.height.offset(1);
    }];
    
    return view;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    RefundCell *cell=[RefundCell theShareCellWithTableView:tableView];
    //    OrderModel *model=self.orderList[indexPath.section];
    //    NSMutableArray *data=model.goods_list;
    //    GoodsListModel *goodsModel=data[indexPath.row];
    //    cell.model=goodsModel;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    self.hidesBottomBarWhenPushed=YES;
    ApplyRefundVC *evaluate=[[ApplyRefundVC alloc]init];
    [self.navigationController pushViewController:evaluate animated:YES];
    
    //        weakSelf.hidesBottomBarWhenPushed=YES;
    //        RefundScheduleVC *evaluate=[[RefundScheduleVC alloc]init];
    //        [weakSelf.navigationController pushViewController:evaluate animated:YES];

}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
